<template>
  <div class="insurance">
    <!-- max-width:750px; 此宽度用于整体页面固定时-->
    <scroller v-show="!isWeChar" :lock-x="true" :lock-y="true" style="width:100%;height:46px;z-index:2;">
      <div class="insurance__head">
        <x-header>
          <div slot="default" @click="test" class="common__header--title">{{ $t('moreInsurance') }}</div>
          <div @click="goBack" slot="overwrite-left" class="common__header--img"><img slot="icon" src="~assets/x3/ico/goback1.png" class="go-back"></div>
        </x-header>
      </div>
    </scroller>
    <insurance-list></insurance-list>
  </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import { RequestUrl } from "src/common/url";
import InsuranceList from "src/components/insurance/insuranceList";
import SharePage from "src/js/sharePage"; //引入微信分享js
import { FooterIndex, Mutations, RouteUrl, WE_CHAT, Url_Key } from "src/common/const";
import vueScroller from "src/common/vueScroller/components/Scroller";
import { XHeader, CheckerItem, Group, Scroller, Checker, Cell, XButton, Panel } from "vux";
export default {
  computed: mapState(["insureBaseInfo", "riskCodeList", "insurance", "user", "saveInsure", "isWeChar", "shareUuid", "detailsStore", "isWeAuth"]),
  components: {
    vueScroller,
    Group,
    XHeader,
    Cell,
    Scroller,
    Checker,
    CheckerItem,
    InsuranceList
  },
  watch: {
    isWeChar(cur, old) {
      this.initScPage();
    }
  },
  data() {
    return {
    };
  },
  methods: {
    test() {
      // this.$common.goUrl(this, RouteUrl.PRODUCT_MANAGE);
    },
    onScrollBottom() { },
    goBack() {
      this.$common.goBack(this);
    },
    //初始化分享信息
    initShare() {
      //分享地址初始化
      // let urlParm = {
      //   shareId: this.shareUuid
      // };
      // let shareUrl = window.location.href.split('?')[0] + this.$common.getShareUrl(this, urlParm);
      // alert(this.shareUuid);
      sessionStorage["SHARE_COMMON_TYPE"] = "USER";
      if (this.user.isLogin) {
        let uuid = this.$encode.hex_md5(this.user.userDto.userCode + ":1");
        this.$common.storeCommit(this, Mutations.SET_SHARE_UUID, uuid);
      }
      // alert(1);
      let parmList = [];
      let urlParm = {
        key: Url_Key.SHARE_UUID,
        value: this.shareUuid
      }
      parmList.push(urlParm);

      let shareUrl = RequestUrl.BASE_URL + RouteUrl.INSURANCE + this.$common.setShareUrl(parmList);
      // let test1 = RequestUrl.BASE_URL;
      // let test2 = +"/" + RouteUrl.INSURANCE.split('/')[2];
      //微信分享初始数据
      let weChatData = {
        _this: this,
        shareData: {
          title: "恒华出行宝-产品列表",
          desc: WE_CHAT.shareDesc_Indexs,
          imgUrl: RequestUrl.WEB_PATH + "sticcxb/upload/assets/x3/logo.jpg",
          url: shareUrl,
          _this: this,
          type: 2
        }
      };
      // 微信分享
      SharePage.weChatShare(weChatData);
    },
    initScPage() {
      let data = {
        top: "92",
        btn: "75",
        other: "",
      }
      if (this.isWeChar) {
        data.top = "48";
      }
      this.$common.storeCommit(this, Mutations.SET_IS_SHOP, false);
      this.$common.storeCommit(this, Mutations.INSURANCE_LIST_TOP, data);
      this.$common.storeCommit(this, Mutations.VUE_SCROLLER_BTN, 0);
      this.$common.storeCommit(this, Mutations.VUE_SCROLLER_NO_MORE_DATA, "");
    }
  },
  beforeRouteEnter(to, from, next) {
    localStorage["UUID_REF_URL"] = from.path;
    next();
  },
  beforeDestroy() {
    this.$common.storeCommit(this, Mutations.IS_SHOW_ROUTE_RED, false);
  },
  mounted() {
    sessionStorage["DETAILS_FORM_URL"] = RouteUrl.INSURANCE;

    this.$common.storeCommit(this, Mutations.IS_SHOW_ROUTE_RED, true);


    let _this = this;
    document.title = "恒华出行宝";
    // _this.$common.setUuid(_this);
    this.$init.indexInit(this, FooterIndex.INSURANCE);
    this.initScPage();
    //初始化分享信息
    this.initShare();
  }
};
</script>
<style lang="scss" scoped >
.insurance {
  background-color: #f0f0f0;
}

.insurance__head {
  position: relative;
  width: 100%; // max-width: 750px;
  height: 46px; // background-color: #f95;
  z-index: 2; //auto：默认值。浏览器允许一些手势（touch）操作在设置了此属性的元素上，例如：对视口（viewport）平移、缩放等操作。
  //none：禁止触发默认的手势操作
  //pan-x：可以在父级元素(the nearest ancestor)内进行水平移动的手势操作。
  //pan-y：可以在父级元素内进行垂直移动的手势操作。
  //manipulation：允许手势水平/垂直平移或持续的缩放。任何auto属性支持的额外操作都不支持。
  //touch-action只支持具有CSS width和height属性的元素
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}
</style>
